package com.qk.mapper;

import com.qk.entity.User;
import com.qk.dto.UserDto;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserMapper {
    List<User> selectList(UserDto userDto);
    @Insert("insert into user(username, name,phone, email,gender,status,password,dept_id,role_id, create_time, update_time,image)" +
            " values(#{username},#{name}, #{phone}, #{email}, #{gender}, #{status},#{password}, #{deptId}, #{roleId}, #{createTime}, #{updateTime},#{image})")
    void insert(User user);

    void deleteByIds(List<Integer> ids);
    @Select("select id, username, name,phone, email,gender,status,password,dept_id,role_id, create_time, update_time,image from user where id=#{id}")
    User getById(Integer id);

    void update(User user);

    List<User> listByRole(String roleLabel);
    @Select("select u.* ,r.label  role_label from user u left join role r on u.role_id = r.id where username =#{username}")
    User selectByUsername(String username);
}
